package com.zhq.blog.core.domain.game;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.persistence.Entity;
import javax.persistence.Transient;

import com.zhq.blog.core.domain.BasePersistentDomain;

/**
 * @title:GameBase.java
 * @package com.zhq.blog.core.domain.game
 * @author 张恒强
 * @date 2014年12月25日 下午2:06:16
 * @version V1.0
 */
@Entity
public class Game extends BasePersistentDomain<GameRepository>{
	
	private int frequency; //开奖频率
	
	private int deadline = 5; // 开奖前多少秒不可开奖
	
	private double waterScale = 50; //抽水比例  千分比
	
	private long baseNumber; // 金币基数
	
	private String name;//游戏类型名称
	
	private String fromNumber; //选取数字空间
	
	private int repeatTimes;
	
	private String resultNumber;//奖的结果区间，供前台显示，玩家选择
	
	private String description; //游戏说明
	
	@Transient
	private List<Integer> fromNumberList;
	
	@Transient
	private List<Integer> resultNumberList;
	
	

	public Game() {
		super();
	}
	
	

	public Game(int frequency, long baseNumber, String name, String fromNumber,
			int repeatTimes,String resultNumber) {
		super();
		this.frequency = frequency;
		this.baseNumber = baseNumber;
		this.name = name;
		this.fromNumber = fromNumber;
		this.repeatTimes = repeatTimes;
		this.resultNumber = resultNumber;
	}



	public int getRepeatTimes() {
		return repeatTimes;
	}

	public void setRepeatTimes(int repeatTimes) {
		this.repeatTimes = repeatTimes;
	}

	public int getFrequency() {
		return frequency;
	}

	public void setFrequency(int frequency) {
		this.frequency = frequency;
	}

	public int getDeadline() {
		return deadline;
	}

	public void setDeadline(int deadline) {
		this.deadline = deadline;
	}

	public double getWaterScale() {
		return waterScale;
	}

	public void setWaterScale(double waterScale) {
		this.waterScale = waterScale;
	}

	public long getBaseNumber() {
		return baseNumber;
	}

	public void setBaseNumber(long baseNumber) {
		this.baseNumber = baseNumber;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getFromNumber() {
		return fromNumber;
	}

	public void setFromNumber(String fromNumber) {
		this.fromNumber = fromNumber;
	}

	public String getResultNumber() {
		return resultNumber;
	}

	public void setResultNumber(String resultNumber) {
		this.resultNumber = resultNumber;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@PostConstruct
	public List<Integer> getFromNumberList() {
		if(fromNumberList==null){
			fromNumberList = new ArrayList<Integer>();
			if(fromNumber!=null){
				String[] arr = fromNumber.split(",");
				for(String str:arr){
					fromNumberList.add(Integer.parseInt(str));
				}
			}
		}
		return fromNumberList;
	}

	public void setFromNumberList(List<Integer> fromNumberList) {
		this.fromNumberList = fromNumberList;
	}
	@PostConstruct
	public List<Integer> getResultNumberList() {
		if(resultNumberList==null){
			resultNumberList = new ArrayList<Integer>();
			if(resultNumber!=null){
				String[] arr = resultNumber.split(",");
				for(String str:arr){
					resultNumberList.add(Integer.parseInt(str));
				}
			}
		}
		return resultNumberList;
	}

	public void setResultNumberList(List<Integer> resultNumberList) {
		this.resultNumberList = resultNumberList;
	}

}
